package com.wf.common.rest;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.wf.common.util.HTTPClientIPUtil;
import com.wf.common.util.HttpRequest;

@RestController
@RequestMapping(value="common")
public class CommonRest {

	/**
	 * 返回ip所属地
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/getIpregion",method=RequestMethod.GET,produces="text/html; charset=UTF-8")
	public String getIpregion(HttpServletRequest request){
		String ip=HTTPClientIPUtil.getIP(request);
		return HttpRequest.getIpRegion(ip);
	}
	
	/**
	 * 返回系统当前时间
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/getDateTime",method=RequestMethod.GET)
	public String getDateTime(){
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return formatter.format(new Date(System.currentTimeMillis()));
	}
}
